package com.swl.juc.queue;

public class SeqCount {
    private static ThreadLocal<Integer> numloaval = new ThreadLocal<Integer>(){
        @Override
        protected Integer initialValue(){
            return 0;
        }
    };

        private static Integer num = 0;
        public static void main(String[] args) throws InterruptedException {
            Thread[] threads = new Thread[5];
            for (int i = 0; i < 5; i++) {
                threads[i] = new Thread(()->{
                    num+=5;
                    int x = numloaval.get().intValue();
                    x+=5;
                    numloaval.set(x);
                    System.out.println(Thread.currentThread().getName()+":"+numloaval.get());
                });
            }

            for (int i = 0; i < 5; i++) {
                threads[i].start();
            }
        }

    }